home *** CD-ROM | disk | FTP | other *** search
/ Web Developers Guide to Sound & Music / Web Developers Guide to Sound and Music.iso / mac / Cyber Sounds / SHARED.DIR / 00901_Script_Volume PS next >
Text File  |  1996-01-14  |  2KB  |  55 lines

  1. property pSoundLevel, pThumbSprite, pThumbMin, pThumbMax, pScale
  2.  
  3. on birth me, thumbSprite, thumbMin, thumbMax, initSoundLevel
  4.   set pSoundLevel = initSoundLevel
  5.   set pThumbMin = thumbMin
  6.   set pThumbMax = thumbMax
  7.   set pThumbSprite = thumbSprite
  8.   set pScale = (pThumbMax - pThumbMin) / 7.0
  9.   return me
  10. end
  11.  
  12. on mMoveThumb me
  13.   set theOffset = the locV of sprite pThumbSprite - the mouseV
  14.   repeat while the stillDown
  15.     set newLoc = the mouseV + theOffset
  16.     if newLoc < pThumbMin then set newLoc = pThumbMin
  17.     if newLoc > pThumbMax then set newLoc = pThumbMax
  18.     set the locV of sprite pThumbSprite = newLoc
  19.     go to the frame
  20.   end repeat
  21.   set the soundLevel = mGetNewLevel(me)
  22.   set pSoundLevel = the soundLevel
  23. end
  24.  
  25. on mInit me
  26.   puppetSprite pThumbSprite, 1
  27.   mUpdate(me)
  28. end
  29.  
  30. on mUpdate me
  31.   set the locV of sprite pThumbSprite = mGetNewLoc(me)
  32.   set the soundLevel = pSoundLevel
  33. end
  34.  
  35. on mGetNewLoc me
  36.   set newLoc = pThumbMin + ((7 - pSoundLevel) * pScale)
  37.   if newLoc < pThumbMin then set newLoc = pThumbMin
  38.   if newLoc > pThumbMax then set newLoc = pThumbMax
  39.   return newLoc
  40. end
  41.  
  42. on mGetNewLevel me
  43.   set newLevel = 7 + ((pThumbMin - the locV of sprite pThumbSprite) / pScale)
  44.   if newLevel < 0 then set newLevel = 0
  45.   if newLevel > 7 then set newLevel = 7
  46.   return newLevel
  47. end
  48.  
  49. on dump me
  50.   put "pThumbSprite:"&&pThumbSprite
  51.   put "pThumbMin:"&&pThumbMin
  52.   put "pThumbMax:"&&pThumbMax
  53.   put "pSoundLevel:"&&pSoundLevel
  54.   put "pScale:"&&pScale
  55. end